<template>
	<view>
		<view class="content" v-if="!dataList || dataList.length < 1">
			<u-empty text="所谓伊喵，精神焕发" mode="list"></u-empty>
		</view>
		<view v-else style="padding: 3%;">
			<view v-for="(year,yearIndex) in dataList" :key="yearIndex">
				<text style="font-size: 28px;">
					{{year.key}}年
				</text>
				<view v-for="(month,monthIndex) in year.dailyOwnList" :key="monthIndex">
					<view v-for="(day,dayIndex) in month.dailyOwnList" :key="dayIndex">
						<view style="display: flex;margin: 5% 0;">
							<text style="font-size: 28px;margin-left: 10rpx;flex: 20%;">
								{{day.key}} <text style="font-size: 16px;margin-left: 5rpx;">{{month.key}}月</text>
							</text>
							<view style="flex: 80%;">
								<view v-for="(data,index) in day.dailyList" :key="index" @click="toggleShowMore(data)"
									style="position: relative;"
									:style="{'display': 'flex','margin':'3% 0','background-color':data.sysFileInfos[0].fileUrl ? '' : '#c9c9c9'}">
									<u-image v-if="data.sysFileInfos[0].fileUrl" :src="data.sysFileInfos[0].fileUrl"
										mode="aspectFill" width="200rpx" height="200rpx" :lazy-load="true"></u-image>
									<view x :style="{
										'margin-left':data.sysFileInfos[0].fileUrl ? '10rpx' :'',
									}">
										{{data.content}}
										<view style="position: absolute;bottom: 0rpx;right: 0rpx;">
											<u-icon name="lock-fill" size="34" v-if="data.isHide == 1"></u-icon>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore status="nomore" />
		</view>
	</view>
</template>

<script>
	import {
		getDailyOwnList,
	} from '@/api/bot/daily'
	export default {
		data() {
			return {
				query: {
					pageNum: 1,
					pageSize: 10,
					ownData: true,
					groupId: ''
				},
				dataList: [],
				maxContentLength: 30
			}
		},
		onLoad() {
			uni.getStorage({
				key: 'groupIdByIndex',
				success: (res) => {
					let data = JSON.parse(res.data);
					this.query.groupId = data.id;
					this.getDailyOwnList()
				}
			});
		},
		onPullDownRefresh() {
			this.getDailyOwnList()
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1500)
		},
		methods: {
			getDailyOwnList() {
				uni.showLoading({
					title: '加载中...'
				})
				getDailyOwnList(this.query).then(res => {
					this.dataList = res.rows;
					uni.hideLoading()
				}).catch(error => {
					uni.hideLoading()
				})
			},
			toggleShowMore(data) {
				const formDataStr = JSON.stringify(data);
				this.$tab.navigateTo('/pages/detail/dailyDetail?data=' + encodeURIComponent(formDataStr))
			},
		}
	}
</script>

<style lang="scss" scoped>
	.u-card-wrap {
		background-color: $u-bg-color;
		padding: 1px;
	}

	.u-body-item {
		font-size: 32rpx;
		color: #333;
		padding: 20rpx 10rpx;
	}

	.u-body-item image {
		width: 120rpx;
		flex: 0 0 120rpx;
		height: 120rpx;
		border-radius: 8rpx;
		margin-left: 12rpx;
	}

	.content {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-top: 10%;
	}

	.content {
		height: 100%;
	}

	.scroll scroll-view {
		height: 100%;
	}
</style>